<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.29
     from deftbl.tnf on 19 December 2010 -->

<TITLE>Definition Table - The Definition Table Module</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000" BACKGROUND="gifs/bg.gif">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0" VALIGN=BOTTOM>
<TR VALIGN=BOTTOM>
<TD WIDTH="160" VALIGN=BOTTOM>
<A HREF="http://eli-project.sourceforge.net/">
<IMG SRC="gifs/elilogo.gif" BORDER=0>
</A>&nbsp;
</TD>
<TD WIDTH="25" VALIGN=BOTTOM>
<img src="gifs/empty.gif" WIDTH=25 HEIGHT=25>
</TD>
<TD ALIGN=LEFT WIDTH="475" VALIGN=BOTTOM>
<A HREF="index.html"><IMG SRC="gifs/title.png" BORDER=0></A>
</TD>
<!-- |DELETE FOR SOURCEFORGE LOGO|
<TD>
<a href="http://sourceforge.net/projects/eli-project">
<img
  src="http://sflogo.sourceforge.net/sflogo.php?group_id=70447&amp;type=13"
  width="120" height="30"
  alt="Get Eli: Translator Construction Made Easy at SourceForge.net.
    Fast, secure and Free Open Source software downloads"/>
</a>
</TD>
|DELETE FOR SOURCEFORGE LOGO| -->
</TR>
</TABLE>

<HR size=1 noshade width=785 align=left>
<TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0>
<TR>
<TD VALIGN=TOP WIDTH="160">
<h4>General Information</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="index.html">Eli: Translator Construction Made Easy</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gindex_1.html#SEC1">Global Index</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="faq_toc.html" >Frequently Asked Questions</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Tutorials</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="EliRefCard_toc.html">Quick Reference Card</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="novice_toc.html">Guide For new Eli Users</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="news_toc.html">Release Notes of Eli</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="nametutorial_toc.html">Tutorial on Name Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="typetutorial_toc.html">Tutorial on Type Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Reference Manuals</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ui_toc.html">User Interface</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="pp_toc.html">Eli products and parameters</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lidoref_toc.html">LIDO Reference Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Libraries</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lib_toc.html">Eli library routines</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="modlib_toc.html">Specification Module Library</a></td></tr>
</table>

<h4>Translation Tasks</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lex_toc.html">Lexical analysis specification</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="syntax_toc.html">Syntactic Analysis Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="comptrees_toc.html">Computation in Trees</a></td></tr>
</table>

<h4>Tools</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lcl_toc.html">LIGA Control Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="show_toc.html">Debugging Information for LIDO</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gorto_toc.html">Graphical ORder TOol</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="fw_toc.html">FunnelWeb User's Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ptg_toc.html">Pattern-based Text Generator</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="deftbl_toc.html">Property Definition Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="oil_toc.html">Operator Identification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="tp_toc.html">Tree Grammar Specification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="clp_toc.html">Command Line Processing</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="cola_toc.html">COLA Options Reference Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="idem_toc.html">Generating Unparsing Code</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="mon_toc.html">Monitoring a Processor's Execution</a> </td></tr>
</table>

<h4>Administration</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="sysadmin_toc.html">System Administration Guide</a> </td></tr>
</table>

<HR WIDTH="100%">
<A HREF="mailto:eli-project-users@lists.sourceforge.net">
<IMG SRC="gifs/button_mail.gif" BORDER=0 ALIGN="left"></A>
<A HREF="index.html"><IMG SRC="gifs/home.gif" BORDER=0 ALIGN="right"></A>

</TD>
<TD VALIGN=TOP WIDTH="25"><img src="gifs/empty.gif" WIDTH=25 HEIGHT=25></TD>

<TD VALIGN=TOP WIDTH="600">
<H1>Definition Table</H1>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="deftbl_2.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="deftbl_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
<H1><A NAME="SEC1" HREF="deftbl_toc.html#SEC1">The Definition Table Module</A></H1>
<P>
The definition table module embodies the concept of a set of
distinguishable entities, each having some set of properties.
There is at least one entity, the invalid entity;
it has an empty set of properties.
No other entities exist unless they are explicitly created.
Nothing is assumed about entities, other than the fact that they are
distinguishable.
<P>
Each distinct entity is represented by a distinct key.
The module exports a key representing the invalid entity, and
an operation that creates a new key each time it is invoked.
<P>
Properties are declared by the user.
Each property declaration specifies the type of data item that defines the
property, but does not associate the property with any specific entity or
entities.
<P>
Query and update operations are used to associate property values with
entities.
Each query or update operation is defined for a single property, and
an invocation associates a single value of the declared type
with the entity to which the operation is applied.
<P>
To make the definition table module accessible to a program,
include the header file <TT>`deftbl.h'</TT> in that program.
<A NAME="IDX1"></A>
<P>
<H2><A NAME="SEC2" HREF="deftbl_toc.html#SEC2">How to create and use definition table keys</A></H2>
<P>
Definition table keys are objects of type <CODE>DefTableKey</CODE>.
<A NAME="IDX3"></A>
<A NAME="IDX2"></A>
<CODE>DefTableKey</CODE> is a private type of the definition table module:
Clients of the definition table module may declare variables and parameters
of type <CODE>DefTableKey</CODE>, but they must make no assumptions about its
representation.
<P>
The invalid key is <CODE>NoKey</CODE>, a legal value of type <CODE>DefTableKey</CODE>. 
<A NAME="IDX5"></A>
<A NAME="IDX4"></A>
No property values are ever associated with <CODE>NoKey</CODE>.
<P>
<CODE>NewKey</CODE> is a parameterless function that yields a value of type
<A NAME="IDX6"></A>
<CODE>DefTableKey</CODE> each time it is invoked.
All of these values are distinct from each other and from <CODE>NoKey</CODE>.
Any client of the definition table module may invoke <CODE>NewKey</CODE>.
<A NAME="IDX7"></A>
<P>
Definition table keys are often bound to identifiers via the
environment module operation <CODE>DefineIdn</CODE>
<A NAME="IDX9"></A>
<A NAME="IDX8"></A>
(see  <A HREF="lib_1.html#SEC9">Contour-Model Environment Module of Library Reference Manual</A>).
In this case <CODE>DefineIdn</CODE> will invoke <CODE>NewKey</CODE> if necessary;
<CODE>NewKey</CODE> should be invoked directly <EM>only</EM> for entities that
are not under control of the environment module.
<P>
It is sometimes useful to be able to get a new key that is just like an
existing one.  The <CODE>CloneKey</CODE>
<A NAME="IDX11"></A>
<A NAME="IDX10"></A>
operation takes a single key as argument, uses <CODE>NewKey</CODE> to get a
new one, and initialises the properties of the new key to be the same as
those of the key argument.  The new key is returned.
<P>
Note that <CODE>CloneKey</CODE> implements shallow-copying of property values.
For example, if a property value of the key argument is a pointer then
after the <CODE>CloneKey</CODE> call two keys will have properties pointing to
the same data.
<P>
<H2><A NAME="SEC3" HREF="deftbl_toc.html#SEC3">How to declare properties</A></H2>
<P>
Each property has a <DFN>name</DFN> and a <DFN>type</DFN>.
<A NAME="IDX13"></A>
<A NAME="IDX12"></A>
<P>
A property type is denoted by a C identifier (a sequence of letters,
digits and underscores that does not begin with a digit).
Property types must either be built-in types of C (such as <CODE>int</CODE>),
or they must be declared via <CODE>typedef</CODE> in some accessible module.
The definition table module then becomes a client of the module defining
the property type.
<P>
A property name is also denoted by a C identifier.
Property names must be unique, and must be declared in a file of type
<A NAME="IDX14"></A>
<CODE>.pdl</CODE>.
<A NAME="IDX15"></A>
The simplest form of declaration is:
<P>
<PRE>
Name: Type;
<A NAME="IDX16"></A>
</PRE>
<P>
Here <CODE>Name</CODE> is the property name being declared and <CODE>Type</CODE> is the
data type of the possible values for that property.
<P>
Any type that can be returned by a function can be used as the type of a
property.
If the type is declared via <CODE>typedef</CODE>, some <CODE>.pdl</CODE> file must
contain a C string (sequence of characters delimited by <KBD>"</KBD> characters)
that specifies the name of the file containing that declaration.
<P>
<H2><A NAME="SEC4" HREF="deftbl_toc.html#SEC4">Behavior of the basic query operations</A></H2>
<P>
Each declared property has a basic query operation.
<A NAME="IDX17"></A>
If the name declared for the property is <CODE>Name</CODE>, then the
basic query operation is a function named <CODE>GetName</CODE>.
<A NAME="IDX18"></A>
If property <CODE>Name</CODE> has been declared to have values of type
<CODE>Type</CODE>, then the function implementing the basic query
operation has the following prototype:
<P>
<PRE>
Type GetName(DefTableKey key, Type deflt)
</PRE>
<P>
If <CODE>GetName</CODE> is applied to a definition table key with which a value
of the <CODE>Name</CODE> property has been associated,
then <CODE>GetName</CODE> returns the associated value.
Otherwise it returns the value of parameter <CODE>deflt</CODE>.
<P>
Since <CODE>NoKey</CODE> represents an invalid entity that never has associated
<A NAME="IDX19"></A>
property values, applying any basic query operation to <CODE>NoKey</CODE>
will yield the value of parameter <CODE>deflt</CODE>.
<P>
<H2><A NAME="SEC5" HREF="deftbl_toc.html#SEC5">Behavior of the basic update operations</A></H2>
<P>
Each declared property is has two basic update operations.
<A NAME="IDX20"></A>
If the name declared for the property is <CODE>Name</CODE>, then the
basic update operations are functions named <CODE>SetName</CODE>
and <CODE>ResetName</CODE>.
<A NAME="IDX22"></A>
<A NAME="IDX21"></A>
If property <CODE>Name</CODE> has been declared to have values of type
<CODE>Type</CODE>, then the functions implementing the basic update
operations have the following prototypes:
<P>
<PRE>
void SetName(DefTableKey key, Type add, Type replace)
void ResetName(DefTableKey key, Type val)
</PRE>
<P>
If <CODE>SetName</CODE> is applied to a definition table key with which a value
of the <CODE>Name</CODE> property has been associated, then that value is
replaced by the value of parameter <CODE>replace</CODE>.
Otherwise the value of parameter <CODE>add</CODE> becomes the value of the
<CODE>Name</CODE> property associated with that definition table key.
Application of <CODE>ResetName</CODE> to a definition table key always
results in the value of the <CODE>Name</CODE> property being set to <CODE>val</CODE>.
<P>
Since <CODE>NoKey</CODE> represents an invalid entity that has no associated
<A NAME="IDX23"></A>
property values, applying any basic update operation to <CODE>NoKey</CODE>
has no effect.
<P>
<H2><A NAME="SEC6" HREF="deftbl_toc.html#SEC6">A simple definition table application</A></H2>
<A NAME="IDX24"></A>
<P>
<DFN>Defining occurrences</DFN> of identifiers are the points at which those
identifiers are declared, while <DFN>applied occurrences</DFN> are points at
which they are used.
In many programming languages, it is possible to distinguish defining
occurrences from applied occurrences on the basis of context.
Let us assume that this is the case, and use the definition table to verify
that each identifier has exactly one defining occurrence.
<P>
The environment module is used to implement the scope rules of the
language, binding a definition table key to each occurrence of an identifier.
Within each individual scope, the same key will be bound to all
occurrences of a particular identifier.
To verify that there is a single defining occurrence,
associate a property <CODE>Def</CODE> with the definition table key.
<P>
<CODE>Def</CODE> is of type integer, and three values are significant:
<P>
<DL COMPACT>
<DT><CODE>0</CODE>
<DD>There is no defining occurrence
<P>
<DT><CODE>1</CODE>
<DD>There is exactly one defining occurrence
<P>
<DT><CODE>2</CODE>
<DD>There is more than one defining occurrence
</DL>
<P>
At each defining occurrence, the update operation <CODE>SetDef</CODE> is invoked
with the <CODE>add</CODE> parameter <CODE>1</CODE> and the <CODE>replace</CODE> parameter
<CODE>2</CODE>.
After all defining occurrences are processed, the <CODE>Def</CODE> property value
<CODE>1</CODE> will be associated with the definition table key for each
identifier having exactly one defining occurrence.
The <CODE>Def</CODE> property value <CODE>2</CODE> will be associated with the
definition table key for each identifier having more than one defining
occurrence, and there won't be any <CODE>Def</CODE> property value associated
with the definition table key for each identifier without defining
occurrences.
<P>
At each applied occurrence, the query operation <CODE>GetDef</CODE> is invoked  
with the <CODE>deflt</CODE> parameter <CODE>0</CODE>.
If the identifier has one or more defining occurrences, <CODE>GetDef</CODE> will
yield the <CODE>Def</CODE> property value (either <CODE>1</CODE> or <CODE>2</CODE>)
associated with the definition table key for the applied occurrence.
Otherwise there will be no <CODE>Def</CODE> property value associated with the
definition table key for the applied occurrence, and <CODE>GetDef</CODE> will
yield the value of the <CODE>deflt</CODE> parameter: <CODE>0</CODE>.
<P>
<HR size=1 noshade width=600 align=left>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="deftbl_2.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="deftbl_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
</TD>
</TR>
</TABLE>

</BODY></HTML>
